import{D as e,E as t,Ht as n,On as r,St as i,Zn as a,_ as o,b as s,bt as c,ct as l,g as u,k as d,mt as f,o as p,qt as m,tr as h,v as g,vn as _,y as v}from"./CIxmKYxc4tZcJF.js";import{f as y}from"./CrVzHk_r1oIxh7.js";import{t as b}from"./99kMqMDA3QLL4T.js";import{n as x,t as S}from"./EmVoeTTj1xgU82.js";import{t as C}from"./C8qu1Ngo1zNLPS.js";import{g as w,h as T}from"./BhoLY8NaRMpjn.js";var E={key:0,class:`stack-admin-muted`},D={key:1,class:`stack-admin-error`},O={key:2,class:`stack-admin-nav`},k={key:0,class:`stack-admin-schemas`},A=d({__name:`admin-layout`,setup(d){let A=S(),j=T(),M=w(),N=_([]),P=_(!0),F=_(),I=y(`stack-admin.last-wid`,null),L=u(()=>{let e=j.params.wid;return typeof e==`string`?e:void 0});return n(L,e=>{e&&(I.value=e)}),l(async()=>{try{N.value=await A.client.listWorkspaces()}catch(e){F.value=e.message}finally{P.value=!1}if(L.value||N.value.length===0)return;let e=I.value&&N.value.some(e=>e.wid===I.value)?I.value:N.value[0].wid;await M.replace({name:`stack-admin-workspace`,params:{wid:e}})}),(n,l)=>{let u=i(`router-link`),d=i(`router-view`);return f(),g(r(x),{class:`stack-admin`},{default:m(()=>[e(r(b),{name:`stack-admin-sidebar`,side:`right`,size:240,"min-size":160,"max-size":480,class:`stack-admin-sidebar`},{default:m(()=>[e(u,{to:{name:`stack-admin-home`},class:`stack-admin-title`},{default:m(()=>[o(`strong`,null,h(r(A).title),1)]),_:1}),l[0]||=o(`div`,{class:`stack-admin-section-label`},` Workspaces `,-1),P.value?(f(),s(`div`,E,` Loading… `)):F.value?(f(),s(`div`,D,h(F.value),1)):(f(),s(`nav`,O,[(f(!0),s(p,null,c(N.value,n=>(f(),s(p,{key:n.wid},[e(u,{to:{name:`stack-admin-workspace`,params:{wid:n.wid}},class:a([`stack-admin-ws`,{_active:L.value===n.wid}])},{default:m(()=>[t(h(n.wid),1)]),_:2},1032,[`to`,`class`]),L.value===n.wid?(f(),s(`div`,k,[(f(!0),s(p,null,c(r(A).schemas,e=>(f(),g(u,{key:e.type,to:{name:`stack-admin-schema`,params:{wid:n.wid,type:e.type}},class:`stack-admin-schema`},{default:m(()=>[t(h(e.type),1)]),_:2},1032,[`to`]))),128))])):v(``,!0)],64))),128))]))]),_:1}),e(r(C),{class:`stack-admin-main`},{default:m(()=>[e(d)]),_:1})]),_:1})}}});export{A as default};